#include<stdio.h>
int gys(int x ,int y){
	int  m;
	m=x%y;
	while(m){
		x=y;
		y=m;
		m=x%y;
	}
		
	
	

	return (y) ;
} 
int main()
{
	int x,y,n;
	scanf("%d %d",&x,&y);
	n=gys(x,y);
	printf("%d",n);

 } 
